package jsyf.oa.web.returnVisit;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.returnVisit.ReturnVisitFacade;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by 92852 on 2018/6/27.
 */
@Api(value = "人员回访", description = "人员回访")
@Controller
@RequestMapping("/returnVisit")
public class ReturnVisitController {
    @Resource
    private ReturnVisitFacade returnVisitFacade;

    @ResponseBody
    @RequestMapping(value = "/save.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "保存回访问题",
            notes = "保存回访问题",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'returnVisitEntity':''}", dataType = "String", paramType = "body")
    public void save(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = returnVisitFacade.save(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrHourTimeRespond(records));
    }

    @ResponseBody
    @RequestMapping(value = "/getListInfo.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取列表信息",
            notes = "获取列表信息",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'dateTime':''}", dataType = "String", paramType = "body")
    public void getListInfo(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = returnVisitFacade.getListInfo(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjHourRespond(records));

    }
    @ResponseBody
    @RequestMapping(value = "/getPersonalByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取个人信息",
            notes = "获取个人信息",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':''}", dataType = "String", paramType = "body")
    public void getPersonalByUserId(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = returnVisitFacade.getPersonalByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjHourRespond(records));

    }




}
